/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entite;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author david.tamisier
 */
@Entity
@Table(name = "reponse", catalog = "feedbackform", schema = "")
public class Reponse implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @Column(name = "libelle", nullable = false, length = 65535)
    private String libelle;    
    @Column(name = "cheminImage", length = 255)
    private String cheminImage;
    @Column(name = "ordre")
    private Integer ordre;
    @Column(name = "solution")
    private Boolean solution;
    @Enumerated(EnumType.STRING)
    @Column(name = "idTypeReponse")
    private TypeReponseEnum typeReponse;
    @JoinColumn(name = "idQuestion", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Question question;
    
    /**
     *
     */
    public Reponse() {
    }

    /**
     *
     * @param id
     */
    public Reponse(Integer id) {
        this.id = id;
    }

    /**
     *
     * @param id
     * @param libelle
     */
    public Reponse(Integer id, String libelle) {
        this.id = id;
        this.libelle = libelle;
    }

    /**
     *
     * @return
     */
    public Integer getId() {
        return id;
    }

    /**
     *
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     *
     * @return
     */
    public String getLibelle() {
        return libelle;
    }

    /**
     *
     * @param libelle
     */
    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }
    
    /**
     *
     * @return
     */
    public String getCheminImage() {
        return System.getProperty("user.dir") + cheminImage;
    }
    
    /**
     *
     * @param cheminImage
     */
    public void setCheminImage(String cheminImage) {
        this.cheminImage = cheminImage;
    }
    
    /**
     *
     * @return
     */
    public Integer getOrdre() {
        return ordre;
    }

    /**
     *
     * @param ordre
     */
    public void setOrdre(Integer ordre) {
        this.ordre = ordre;
    }

    /**
     *
     * @return
     */
    public Boolean getSolution() {
        return solution;
    }

    /**
     *
     * @param solution
     */
    public void setSolution(Boolean solution) {
        this.solution = solution;
    }

    /**
     *
     * @return
     */
    public Question getQuestion() {
        return question;
    }

    /**
     *
     * @param question
     */
    public void setQuestion(Question question) {
        this.question = question;
    }

    /**
     *
     * @return
     */
    public TypeReponseEnum getTypeReponse() {
        return typeReponse;
    }

    /**
     *
     * @param typeReponse
     */
    public void setTypeReponse(TypeReponseEnum typeReponse) {
        this.typeReponse = typeReponse;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reponse)) {
            return false;
        }
        Reponse other = (Reponse) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entite.Reponse[id=" + id + "]";
    }

}
